package com.jvm123.api.config

import com.jvm123.api.api.client.PostsClient
import feign.Feign
import feign.gson.GsonDecoder
import feign.gson.GsonEncoder
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
 *
 * @author yawn http://jvm123.com
 *     2019/11/30 14:46
 */
@Configuration
class FeignConfig {

    @Value('${feign.host}')
    String host = "https://blog.jvm123.com"

    @Bean
    PostsClient postsClient() {
        return Feign.builder()
                .encoder(new GsonEncoder())
                .decoder(new GsonDecoder())
                .target(PostsClient.class, host)

    }
}
